﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace DefineGenerated.DAL
{
    public static class XmlHelp
    {
        /// <summary>
        /// 遍历xml下所有元素包含子元素,仅遍历XmlElement
        /// </summary>
        /// <param name="enumerator">xml迭代器</param>
        /// <param name="xls">结果</param>
        public static void EnumeratorXML(IEnumerator enumerator, List<XmlLinkedNode> xls)
        {
            while (enumerator.MoveNext())
            {
                XmlLinkedNode linkedNode = (XmlLinkedNode)enumerator.Current;
                if (linkedNode.NodeType == XmlNodeType.Element)
                {
                    xls.Add(linkedNode);
                }
                EnumeratorXML(linkedNode.GetEnumerator(), xls);
            }

        }
        public static void EnumeratorXML(IEnumerator enumerator, List<XmlLinkedNode> xls, Func<XmlLinkedNode, bool> filter)
        {
            while (enumerator.MoveNext())
            {
                XmlLinkedNode linkedNode = (XmlLinkedNode)enumerator.Current;

                if (filter(linkedNode))
                {
                    xls.Add(linkedNode);
                }
                EnumeratorXML(linkedNode.GetEnumerator(), xls, filter);

            }

        }




    }
}
